package common.server.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.Valid;

/**
 * 内部请求报文
 * 
 * @author Administrator
 * @version [版本号, 2017/11/14 0014]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@ApiModel(value = "InsideRequestMessage",description = "统一请求封装对象，所有请求抽象参数对象")
public class InsideRequestMessage<T extends BaseBody>  extends Message {

    /**
     * 请求体
     */
    @Valid
    @ApiModelProperty(value = "具体报文实体")
    private T reqBody;

    /**
     * 构建请求报文
     * @param reqBody
     * @param <E>
     * @return
     */
    public static <E extends BaseBody> InsideRequestMessage<E> buildNewRequest(E reqBody){
          return new InsideRequestMessage().setReqBody(reqBody);
    }

    public T getReqBody() {
        return reqBody;
    }

    public InsideRequestMessage<T> setReqBody(T reqBody) {
        this.reqBody = reqBody;
        return this;
    }

    @Override
    public String toString() {
        return "InsideRequestMessage{" +
                "reqBody=" + reqBody +
                '}';
    }
}
